//
//  MKUITabBarItemSeparatorView.m
//  MKUI
//
//  Created by 苏尚进 on 2020/8/28.
//  Copyright © 2020 moon. All rights reserved.
//

#import "MKUITabBarItemSeparatorView.h"
#import "UIColor+MKUI.h"
@interface MKUITabBarItemSeparatorView()
@property(nonatomic,strong) UIView *separatorLine;
@end

@implementation MKUITabBarItemSeparatorView
- (id)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        self.separatorLine = [[UIView alloc] init];
        [self addSubview:self.separatorLine];
        self.userInteractionEnabled = NO;
        self.separatorLine.backgroundColor = [self.class separatorColor];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGRect bounds = self.bounds;
    CGRect f = UIEdgeInsetsInsetRect(bounds, [self.class contentInsets]);
    self.separatorLine.frame = f;
}
+ (CGFloat)separatorWidth{
    return 1;
}
+ (UIColor *)separatorColor{
    return [UIColor mk_colorWithLight:[UIColor grayColor] dark:[UIColor lightTextColor]];
}
+ (UIEdgeInsets)contentInsets{
    return UIEdgeInsetsMake(5, 0, 5, 0);
}
- (CGSize)sizeThatFits:(CGSize)size{
    CGSize s = size;
    UIEdgeInsets insets = [self.class contentInsets];
    s.width = [self.class separatorWidth];
    s.width += insets.left+insets.right;
    return s;
}
@end
